import { byFile,_filename } from "../utils/tool.js";

let filname=_filename(import.meta.url);

let shortname=byFile(filname);
async function fn_getAll(ctx){
   ctx.body="获得所有用户"
};
async function fn_getByid(ctx){
    let id=ctx.params.id;
    ctx.body=`获取用户${id}的id`;
};

async function fn_post(ctx){
    ctx.body="新增一个"
}
async function fn_put(ctx){
    ctx.body="修改一个"
}
async function fn_del(ctx){
    ctx.body="删除一个"
}

// export default {
//     'get /user':fn_getAll,
//     'get /user/:id?':fn_getByid,
//     'post /user':fn_post,
//     'put /users/:id?': fn_put,
//     'del /users/:id?': fn_del,
// }
let obj={};

obj[`get /${shortname}`]=fn_getAll;
obj[`get /${shortname}/:id?`] = fn_getByid;
obj[`post /${shortname}`] = fn_post;
obj[`put /${shortname}/:id?`] = fn_put;
obj[`del /${shortname}/:id?`] = fn_del;

export default obj;
